home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 10.5 KB | 356 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMnuItm.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMNUITM_H
- #define FWMNUITM_H
-
- #ifndef FWMENUS_K
- #include "FWMenus.k"
- #endif
-
- #ifndef FWODTYPS_H
- #include "FWODTyps.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWTCOLL_H
- #include "FWTColl.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CPullDownMenu;
- class FW_CString;
- class FW_CMenuBar;
-
- //========================================================================================
- // Defines
- //========================================================================================
-
- typedef short FW_MenuKey;
-
- #ifdef FW_BUILD_MAC
- const FW_MenuKey FW_kPrivMacMenuKeyCharMask = 0x00FF;
- const short FW_kPrivMacScriptCodeKeyEquivalent = 28; // key equiv value of $1C indicates that the icon field contains a script code
- #endif
-
- const ODMenuID FW_kFirstMenuID = 4;
-
-
-
- //========================================================================================
- // class FW_CMenuItem
- //========================================================================================
-
- class FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CMenuItem)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CMenuItem(Environment* ev,
- FW_CReadableStream& stream);
- FW_CMenuItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index);
-
- virtual ~FW_CMenuItem();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- ODCommandID GetCommandID(Environment* ev) const;
-
- FW_CPullDownMenu* GetOwnerMenu(Environment* ev) const;
- short GetIndex(Environment* ev) const;
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& stream);
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- virtual void PrivAttach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDetach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDisableAll(Environment* ev);
- virtual void PrivEnableAll(Environment* ev);
- virtual FW_CMenuItem* PrivGetMenuItem(Environment* ev, ODCommandID commandID) const;
-
- virtual FW_CPullDownMenu* PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const;
-
- void PrivSetIndex(Environment* ev, short newIndex);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- #ifdef FW_BUILD_MAC
- ODCommandID fCommandID; // On windows call the toolbox
- #endif
- FW_CPullDownMenu* fOwnerMenu;
- short fIndex; // one-based
- };
-
-
- //========================================================================================
- // class FW_CSeparatorItem
- //========================================================================================
-
- class FW_CSeparatorItem : public FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CSeparatorItem)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CSeparatorItem(Environment* ev,
- FW_CReadableStream& stream);
- FW_CSeparatorItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index);
-
- virtual ~FW_CSeparatorItem();
-
- protected:
- void InitSeparator(Environment* ev, const ODPlatformMenu& platformMenu);
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- virtual void PrivDisableAll(Environment* ev);
- virtual void PrivEnableAll(Environment* ev);
- };
-
-
-
- //========================================================================================
- // class FW_CTextItem
- //========================================================================================
-
- class FW_CTextItem : public FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CTextItem)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CTextItem(Environment* ev,
- FW_CReadableStream& stream);
- FW_CTextItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index,
- const FW_CString& text,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
- virtual ~FW_CTextItem();
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& stream);
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- #ifdef FW_BUILD_MAC
- virtual void PrivAttach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDetach(Environment* ev, FW_CMenuBar* menuBar);
- #endif
- private:
- void PrivInitTextItem(Environment* ev,
- const ODPlatformMenu& platformMenu,
- const FW_CString& text,
- ODCommandID commandID,
- FW_MenuKey menuKey);
-
- };
-
-
-
- //========================================================================================
- // class FW_CToggleItem
- //========================================================================================
-
- class FW_CToggleItem : public FW_CTextItem
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CToggleItem)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CToggleItem(Environment* ev,
- FW_CReadableStream& stream);
- FW_CToggleItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
- virtual ~FW_CToggleItem();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void ToggleItem(Environment* ev, FW_Boolean newState);
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& stream);
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_Boolean fToggleState;
- FW_CString fOtherText;
- };
-
-
-
- //========================================================================================
- // class FW_CSubMenuItem
- //========================================================================================
-
- class FW_CSubMenuItem : public FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CSubMenuItem)
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CSubMenuItem(Environment* ev,
- FW_CReadableStream& stream);
- FW_CSubMenuItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index,
- FW_CPullDownMenu* adoptSubMenu);
- virtual ~FW_CSubMenuItem();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- FW_CPullDownMenu* GetSubMenu(Environment* ev) const;
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& stream);
- static void* Read(FW_CReadableStream& stream, FW_ClassTypeConstant type);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- virtual void PrivAttach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDetach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDisableAll(Environment* ev);
- virtual void PrivEnableAll(Environment* ev);
- virtual FW_CMenuItem* PrivGetMenuItem(Environment* ev, ODCommandID commandID) const;
-
- virtual FW_CPullDownMenu* PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const;
-
- private:
- void PrivInitSubMenu(Environment* ev, const ODPlatformMenu& platformMenu);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_CPullDownMenu* fSubMenu;
- };
-
- //========================================================================================
- // FW_CMenuItem inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuItem::GetOwnerMenu
- //----------------------------------------------------------------------------------------
- inline FW_CPullDownMenu* FW_CMenuItem::GetOwnerMenu(Environment*) const
- {
- return fOwnerMenu;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuItem::GetIndex
- //----------------------------------------------------------------------------------------
- inline short FW_CMenuItem::GetIndex(Environment*) const
- {
- return fIndex;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSubMenuItem::GetSubMenu
- //----------------------------------------------------------------------------------------
- inline FW_CPullDownMenu* FW_CSubMenuItem::GetSubMenu(Environment*) const
- {
- return fSubMenu;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuItem::PrivSetIndex
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuItem::PrivSetIndex(Environment*, short newIndex)
- {
- fIndex = newIndex;
- }
-
- #endif
-